<?php
	echo $this -> Html -> script(array('viewbook.js', 'jquery.validate.js'));
	date_default_timezone_set('UTC');
?>

<script type="text/javascript">
var pathRoot = '<?php echo $this -> Html -> url('/', true); ?>';
</script>

<style>
label.error
{
	color: red;
}
</style>

<?php
	//$arr = array('0'=>'','1'=>'月','2'=>'火','3'=>'水','4'=>'木','5'=>'金','6'=>'土','7'=>'日');
	$arr7Day = array('1'=>'月曜','2'=>'火曜','3'=>'水曜','4'=>'木曜','5'=>'金曜','6'=>'土曜','7'=>'日曜');
	$optionId = 1;
?>
<div class="viewbook_border_main">
	<?php
		echo $this -> Form -> create('Bookclinic', array('data-ajax'=>'false', 'id'=>'pc_submit'));
	?>
	
	<input type="hidden" id="hdFlg" name="hdFlg">
	
	<div style="margin: 10px auto; width:700px">
		<select name="rank" id="rank">
           <?php 
           		for ($i = 5 ; $i <= 30 ; $i = $i + 5) {
					if ($i != 25) {
						if ($rank == $i) {
							echo "<option value='" . $i . "' selected='selected'>" . $i . "</option>";			
						} else {
							echo "<option value='" . $i . "'>" . $i . "</option>";	
						}
					}
				}
           ?>
        </select>
	</div>
	
	<div style="margin: 10px auto; width:700px">
		<div style="float: left;">
			<div class="border_2_title">
				曜日
			</div>
			<div style="float:left;">
					<?php 
						$int7Day1 = 1;
						while ($int7Day1 < 8) {
							echo "<div class='border_area'>";
							echo "<span>" . $arr7Day[$int7Day1] . "</span>";
							if ($arrStatus[$int7Day1 - 1] == 1) {
								echo "<input type='submit' id='btnClear" . $int7Day1 . "' name='btnClear" . $int7Day1 . "' onclick='setVisable(1," . $int7Day1 . ")' value='休診'>";
							} else {
								echo "<input type='submit' id='btnClear" . $int7Day1 . "' name='btnClear" . $int7Day1 . "' onclick='setVisable(2," . $int7Day1 . ")' value='休診'>";
							}
							echo "</div>";
							$int7Day1++;
						}
					?>
			</div>
		</div>
		<div style='float: left;'>
		<div class='border_2_title'>
			午前
		</div>
		<?php 
		$int7Day2 = 2;
		while ($int7Day2 < 9) {
			echo "<div class='border_area'>";
			if ($arrStatus[$int7Day2 - 2] == 1) {
				echo "<select id='startMorningH_" . $optionId . "' name='startMorningH[" . $optionId . "]' class='setPlan startMor'>";
			} else {
				echo "<select id='startMorningH_" . $optionId . "' disabled='disabled' name='startMorningH[" . $optionId . "]' class='setPlan startMor'>";
			}
			
			$flagMorStart = null;
			for ($i = 7 ; $i < 12 ; $i++) {
				if ($arrStartMor[$int7Day2 - 2] == $i) {
					$flagMorStart = $i;
					echo "<option value='" . $i . "' selected='selected'>" . $i . "</option>";			
				} else {
					echo "<option value='" . $i . "'>" . $i . "</option>";	
				}
			}

			echo "</select>";
			if ($arrStatus[$int7Day2 - 2] == 1) {
				echo "<select id='endMorningH_" . $optionId . "' name='endMorningH[" . $optionId . "]' class='setPlan endMor'>";	
			} else {
				echo "<select id='endMorningH_" . $optionId . "' disabled='disabled' name='endMorningH[" . $optionId . "]' class='setPlan endMor'>";	
			}
			
			if ($flagMorStart == null) {
				$numberMorStart = 7;
			} else {				
				$numberMorStart = $flagMorStart;
			}
			
			for ($i = $numberMorStart ; $i < 13 ; $i++) {
				if ($arrEndMor[$int7Day2 - 2] == $i) {
					echo "<option value='" . $i . "' selected='selected'>" . $i . "</option>";			
				} else {
					echo "<option value='" . $i . "'>" . $i . "</option>";	
				}
			}
			
			echo "</select>";
			echo "</div>";
			$optionId++;
			$int7Day2++;						
		}
		$optionId = 1;
		?>
		</div>
		<div style='float: left;'>
		<div class='border_2_title'>
			お昼（休診）
		</div>
		<?php 
		$int7Day2 = 2;
		while ($int7Day2 < 9) {
			echo "<div class='border_area'>";
			if ($arrStatus[$int7Day2 - 2] == 1) {
				echo "<select id='startNoonH_" . $optionId . "' name='startNoonH[" . $optionId . "]' class='setPlan startNoo'>";
			} else {
				echo "<select id='startNoonH_" . $optionId . "' disabled='disabled' name='startNoonH[" . $optionId . "]' class='setPlan startNoo'>";
			}
			
			$flagNooStart = null;
			for ($i = 12 ; $i < 17 ; $i++) {
				if ($arrStartNoo[$int7Day2 - 2] == $i) {
					$flagNooStart = $i;
					echo "<option value='" . $i . "' selected='selected'>" . $i. "</option>";			
				} else {
					echo "<option value='" . $i . "'>" . $i . "</option>";	
				}
			}
			echo "</select>";
			if ($arrStatus[$int7Day2 - 2] == 1) {
				echo "<select id='endNoonH_" . $optionId . "' name='endNoonH[" . $optionId . "]' class='setPlan endNoo'>";
			} else {
				echo "<select id='endNoonH_" . $optionId . "' disabled='disabled' name='endNoonH[" . $optionId . "]' class='setPlan endNoo'>";
			}
			
			if ($flagNooStart == null) {
				$numberNooStart = 12;
			} else {				
				$numberNooStart = $flagNooStart;
			}
			
			for ($i = $numberNooStart ; $i < 18 ; $i++) {
				if ($arrEndNoo[$int7Day2 - 2] == $i) {
					echo "<option value='" . $i . "' selected='selected'>" . $i . "</option>";			
				}
				else 
				{
					echo "<option value='" . $i . "'>" . $i . "</option>";	
				}
			}
			echo "</select>";
			echo "</div>";
			$int7Day2++;
			$optionId++;			
		}
		$optionId = 1;
		?>
		</div>
		<div style='float: left;'>
		<div class='border_2_title'>
			午後
		</div>
		<?php 
		$int7Day2 = 2;
		while ($int7Day2 < 9) {
			echo "<div class='border_area'>";
			if ($arrStatus[$int7Day2 - 2] == 1) {
				echo "<select id='startAfternoonH_" . $optionId . "' name='startAfternoonH[" . $optionId . "]' class='setPlan startAft'>";
			} else {
				echo "<select id='startAfternoonH_" . $optionId . "' disabled='disabled' name='startAfternoonH[" . $optionId . "]' class='setPlan startAft'>";
			} 
			
			$flagAftStart = null;
			for ($i = 12 ; $i < 22 ; $i++) {
				if ($arrStartAft[$int7Day2 - 2] == $i) {
					echo "<option value='" . $i . "' selected='selected'>" . $i . "</option>";		
					$flagAftStart = $i;
				} else {
					echo "<option value='" . $i . "'>" . $i . "</option>";	
				}
			}
			echo "</select>";
			if ($arrStatus[$int7Day2 - 2] == 1) {
				echo "<select id='endAfternoonH_" . $optionId . "' name='endAfternoonH[" . $optionId . "]' class='setPlan endAft'>";
			} else {
				echo "<select id='endAfternoonH_" . $optionId . "' disabled='disabled' name='endAfternoonH[" . $optionId . "]' class='setPlan endAft'>";
			}
			
			if ($flagAftStart == null) {
				$numberAftStart = 12;
			} else {				
				$numberAftStart = $flagAftStart;
			}
			
			for ($i = $numberAftStart ; $i < 23 ; $i++) {
				if ($arrEndAft[$int7Day2 - 2] == $i) {
					echo "<option value='" . $i . "' selected='selected'>" . $i . "</option>";			
				} else {
					echo "<option value='" . $i . "'>" . $i . "</option>";
				}
			}
			echo "</select>";
			echo "</div>";
			$int7Day2++;	
			$optionId++;					
		}
		?>
		</div>
		<div style="clear: both;"></div>
		<div class="label_1">
			<span>入力・変更後に登録ボタンを押して下さい</span>
			<input class="button_save_plan" type="submit" id="btnSave1" onclick="submitSave(1,1)" name="btnSave1" value="登録">
		</div>
		<div style="clear: both;"></div>
		<br>
		<br>
		<div id="addArea">	   
		    <table>
		        <tr>
			        <td>
			        	<div  class="label_2">
			        		臨時休み
			        	</div>
			        </td>
		            <td>
		                <input type='text' name='year' id='year' size='4'>年
		                <input type='text' name='month' id='month' size='2'>月
		                <input type='text' name='day' id='day' size='2'>日
		            </td>
		            <td>
		                <select name='startH' id="startH">
		                    <?php for ($i = 0;$i <24; $i++) {
		                        echo "<option value=" . $i . ">". $i . "</option>";
		                    }
		                    ?>
		                </select>
		                <select name='endH' id="endH">
		                    <?php for ($i = 0;$i <24; $i++) {
		                        echo "<option value=" . $i . ">" . $i . "</option>";
		                    }
		                    ?>
		                </select>
		            </td>
		        </tr>
		    </table>	    
		</div>		
		<div id="main">
			<div class="label_1">
				<span>複数登録する際は、１回ずつ登録して下さい。</span>
		    	<input class="button_save_plan" type='submit' id="btnSave2" name='btnSave2' onclick="submitSave(1,2)" value='登録'>
			</div>
			<div style="clear: both;"></div>
			<div>
			    表示切替：<select name="searchMonth" id="searchMonth">
			                <option value="0">全て</option>			                
			                <?php 
			                	for ($i = 1; $i <13; $i++) {
			                        echo "<option value=" . $i . ">" . $i . "</option>";
			                    }
		                    ?>
			          </select>
			          <input type="submit" name="choose" id="choose" onclick="searchMonthVacation()" value="表示">
			</div>
			<div>
			    <table border="1px;" id="tableVacation">
			        <tr>
			            <th width="300px">臨時営業は不要</th>
			            <th width="250px">日付</th>
			            <th width="250px">時間</th>
			            <th width="100px">編集</th>
			        </tr>
			        <tbody>
			            <?php
			                foreach ($vacationArray as $vacation) {
			                    echo "<tr>";
			                    if ($vacation['Vacation']['status'] == 1) {
			                        echo "<td class='td_status1'>臨時営業</td>";
			                    } else {
			                        echo "<td class='td_status2'>臨時休業</td>";
			                    }
			                    echo "<td>".$vacation['Vacation']['date']."</td>";
			                    if ($vacation['Vacation']['timeStart'] == null || $vacation['Vacation']['timeStart'] == null) {
			                        echo "<td>なし</td>";
			                    } else {
			                        echo "<td>" . $vacation['Vacation']['timeStart'] . '~' . $vacation['Vacation']['timeEnd'] . "</td>";
			                    }
			                    echo "<td><input type='button' name='delete' id='delete' value='削除' onclick='submitSave(2," . $vacation['Vacation']['id'] . ")' ></td>";
			                    echo "</tr>";
			                }
			            ?>
		            </tbody>
			    </table>
			</div>
		</div>
		<br>
		<br>
		<div>	   
		    <table>
		        <tr>
			        <td>
			        	<div class="label_2">
			        		年末年始休診
			        	</div>
			        </td>
		            <td>
		                <input type='text' name='year' id='year' size='4'>年
		                <input type='text' name='month' id='month' size='2'>月
		                <input type='text' name='day' id='day' size='2'>日
						から
		                <input type='text' name='year' id='year' size='4'>年
		                <input type='text' name='month' id='month' size='2'>月
		                <input type='text' name='day' id='day' size='2'>日
		            </td>
		        </tr>
		    </table>	    
		</div>
		<div>	   
		    <table>
		        <tr>
			        <td>
			        	<div class="label_2">
			        		祝祭日
			        	</div>
			        </td>
		            <td>
		                <input width="100px" type='text' name='txtDate' id='txtDate'>年の祝祭日登録
		            </td>
		        </tr>
		        <tr>
			        <td></td>
			        <td>
			        	<table border="1px;">
					        <?php 
					        	for ($i = 1 ; $i < 13 ; $i++) {
					        		echo "<tr>";
					        		echo "<td style='width: 65px; text-align: right;'>" . $i . "月</td>";
					        		echo "<td style='width: 65px; text-align: right;'>日</td>";
					        		echo "<td style='width: 65px; text-align: right;'>日</td>";
					        		echo "<td style='width: 65px; text-align: right;'>日</td>";
					        		echo "<td style='width: 65px; text-align: right;'>日</td>";
					        		echo "<td style='width: 65px; text-align: right;'>日</td>";
									echo "<td style='width: 65px; text-align: right;'>日</td>";
									echo "</tr>";
					        	}
					        ?>
					    </table>
			        </td>
		        </tr>
		    </table>	    
		</div>
		<div class="label_1">
			<input type="submit" id="btnSave3" name="btnSave3" class="button_save_plan" onclick="submitSave(1,3)" value="登録">
		</div>
	</div>
	<?php
		echo $this -> Form -> end();
	?>
</div>

	